-
Notifications
You must be signed in to change notification settings - Fork 302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move from AMD and CommonJS to ES6 modules #44
Conversation
Note that this enables ES6 globally (through Babel), so lambdas (the fat-arrow operator), classes, etc. can be used in sources. /cc @Jeremy-Gaillard |
Can we expect easy merging of the other branches by applying the two command lines that you provided before the merging operation? If it is the case, other developers should be aware of it, manually merging ES6 with require code seems painful... |
I'm polishing a followup commit (that I was about to push to the branch) that automatically transforms CommonJS (var XXX = require('XXX')) to ES6 But yes, the idea is that you should be able to copy/paste the commands in your shell to update your working directory. |
78df862
to
505e23e
Compare
Moved everything (AMD and CommonJS) to ES6, rebased on latest |
Moved comment from @nosy-b
|
@nosy-b @Jeremy-Gaillard |
This is an (almost) automated conversion: * first "unname" the AMD modules, sed -i "s|define.'[^']*',|define(|g" $(git grep --name-only -e "define[(]'[^']*',") * then convert them to ES6 modules through amdtoes6. amdtoes6 -d src/ -o src/ -b
This is an automated conversion: find src/ -type f -name "*.js" \ -not -name "*.min.js" -not -name "optimer_regular.js" \ -exec esnext -I -w modules.commonjs {} \; Then processed sources have been js-beautified again (see earlier commit for the command-line used)
|
@@ -26,6 +27,12 @@ | |||
"when": "^1.7.1" | |||
}, | |||
"devDependencies": { | |||
"babel-cli": "^6.5.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, babel-cli
is useless here. It's meant to be installed globally (I personally just added ./node_modules/.bin
to my $PATH
)
This is an (almost) automated conversion:
first "unname" the AMD modules,
then convert them to ES6 modules through amdtoes6 (use
npm install amd-to-es6
to install the tool).finally, convert CommonJS modules to ES6 modules through esnext (use
npm install esnext
to install the tool).